package com.newlink.building.userinfo.mvp

import com.newlink.building.common_base.base.BasePresenter
import com.newlink.building.common_base.ext.ss
import com.newlink.building.userinfo.mvp.contract.Module_UserInfo_AccountInformationChangePhoneInputCodeContract
import com.newlink.building.userinfo.mvp.model.Module_UserInfo_AccountInformationChangePhoneInputCodeModel

/**
 * @author wangyang
 * @date 2022/10/29
 * @description 我的——账户信息——更换手机号页面（第二步：输入验证码）的Presenter
 */
class Module_UserInfo_AccountInformationChangePhoneInputCodePresenter :
    BasePresenter<Module_UserInfo_AccountInformationChangePhoneInputCodeContract.Model, Module_UserInfo_AccountInformationChangePhoneInputCodeContract.View>(),
    Module_UserInfo_AccountInformationChangePhoneInputCodeContract.Presenter {

    override fun createModel(): Module_UserInfo_AccountInformationChangePhoneInputCodeContract.Model? {
        return Module_UserInfo_AccountInformationChangePhoneInputCodeModel()
    }

    override fun getData() {
    }

    override fun sendBindPhoneCode(
        accessToken: String,
        bindArea: String,
        bindPhone: String,
        userId: Long,
        verifyCode: String
    ) {
        mModel?.sendBindPhoneCode(accessToken, bindArea, bindPhone, userId, verifyCode)
            ?.ss(mModel, mView) { result ->
                result?.let {
                    if (it.data.result == 1) {
                        mView?.bindPhoneSuccess()
                    } else {
                        mView?.bindPhoneFailed()
                    }
                }
            }
    }
}